﻿<div bsModal #editRouteModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
    aria-labelledby="createOrEditLibraryModal" aria-hidden="true" [config]="{backdrop: 'static', keyboard: !saving}">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form *ngIf="active" #orderForm="ngForm" >
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span >编号: {{productionId}}</span>
                    </h4>
                    <button type="button" class="close" (click)="close()" [attr.aria-label]="l('Close')"
                        [disabled]="saving">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="row m--margin-top-20">
                        <div class="col-md-6 ">
                            <div class="form-group m-form__group m--margin-10">
                                <label for="picNo">
                                    路线
                                </label>
                                <input id="routeString" #routeStringInput="ngModel" type="text" name="routeString" class="form-control"
                                    [(ngModel)]="routeString" placeholder="制造路线" required maxlength="64">
                                <validation-messages [formCtrl]="routeStringInput"></validation-messages>
                            </div>
                        </div>
                        <div class="col-md-6 m--margin-top-20 ">
                            <div class="form-group m-form__group m--margin-top-20">
                                <button [disabled]="saving" type="button" class="btn btn-primary"
                                (click)="saveRouteString()"> <span>保存路线</span></button>
                                <button type="submit" class="btn btn-default"  (click)="generateRoutes()">
                                <span>生成工时</span></button>
                            </div>
                        </div>
                        <div class="col-md-12 m--margin-bottom-10">
                                <div class="m-checkbox-list">
                                        <label class="m-checkbox">
                                            <input id="EditRole_IsDefault" type="checkbox" name="IsDefault" (change)="changeIstemp()" [(ngModel)]="isTemporaryLaborHour">
                                            临时
                                            <span></span>
                                        </label>
                                        <span class="help-block">临时会在月底计算前提醒，确定工时后再进行计算</span>
                                    </div>
                        </div>
                        <div class="col-md-12 m--margin-bottom-10">
                            <div class="form-group m-form__group m--margin-10">
                                <p-table [value]="routes">
                                    <ng-template pTemplate="header">
                                        <tr>
                                            <th>序号</th>
                                            <th>车间</th>
                                            <th>工种</th>
                                            <th>准结</th>
                                            <th>单件</th>
                                            <th>操作</th>
                                        </tr>
                                    </ng-template>
                                    <ng-template pTemplate="body" let-rowData>
                                        <tr>
                                            <td pEditableColumn>
                                                <p-cellEditor>
                                                    <ng-template pTemplate="input">
                                                        <input pInputText type="text" [(ngModel)]="rowData.index" required name='index'>
                                                    </ng-template>
                                                    <ng-template pTemplate="output">
                                                        {{rowData.index}}
                                                    </ng-template>
                                                </p-cellEditor>
                                            </td>
                                            <td pEditableColumn>
                                                <p-cellEditor>
                                                    <ng-template pTemplate="input">
                                                        <input pInputText type="text" [(ngModel)]="rowData.dpt" required name='dpt'>
                                                    </ng-template>
                                                    <ng-template pTemplate="output">
                                                        {{rowData.dpt}}
                                                    </ng-template>
                                                </p-cellEditor>
                                            </td>
                                            <td pEditableColumn>
                                                <p-cellEditor>
                                                    <ng-template pTemplate="input">
                                                            <p-dropdown [options]="professions" [(ngModel)]="rowData.profession" name="profession" [style]="{'width':'100%'}"></p-dropdown>                                                       
                                                    </ng-template>
                                                    <ng-template pTemplate="output">
                                                        {{rowData.profession}}
                                                    </ng-template>
                                                </p-cellEditor>
                                            </td>
                                            <td pEditableColumn>
                                                <p-cellEditor>
                                                    <ng-template pTemplate="input">
                                                        <input pInputText type="text" [(ngModel)]="rowData.preDuration"  name='preDuration'>
                                                    </ng-template>
                                                    <ng-template pTemplate="output">
                                                        {{rowData.preDuration}}
                                                    </ng-template>
                                                </p-cellEditor>
                                            </td>
                                            <td pEditableColumn>
                                                <p-cellEditor>
                                                    <ng-template pTemplate="input">
                                                        <input pInputText type="text" [(ngModel)]="rowData.duration" name='duration'>
                                                    </ng-template>
                                                    <ng-template pTemplate="output">
                                                        {{rowData.duration}}
                                                    </ng-template>
                                                </p-cellEditor>
                                            </td>
                                            <td >
                                                    <a href="javascript:;" (click)="onDeleteRoute(rowData)" class="btn btn-outline-danger m-btn m-btn--icon btn-sm m-btn--icon-only m-btn--pill">
															<i class="fa flaticon-delete-1"></i>
														</a>
                                            </td>
                                        </tr>
                                    </ng-template>
                                </p-table>
                            </div>
                        </div>
                        
                    </div>

                </div>
                <div class="modal-footer">
                    <button [disabled]="saving" type="button" class="btn btn-default"
                        (click)="close()">{{"Cancel" | localize}}</button>
                    <button type="button" class="btn btn-primary" 
                        [buttonBusy]="saving" [busyText]="l('SavingWithThreeDot')" (click)="saveRoute()"><i class="fa fa-save"></i>
                        <span>{{"Save" | localize}}</span></button>
                </div>
            </form>
        </div>
    </div>
</div>